﻿
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>登录</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="shortcut icon" type="image/png" href="/images/logo.png" />
    <link rel="stylesheet" href="/css/login.css">
</head>

<body>

    <div class="container" id="app" v-cloak="v-cloak">
        <div class="right"></div>
        <div class="left">
            <div class="header">
                <h2 class="animation a1">欢迎回来</h2>
                <h4 class="animation a2">使用账号及密码登入你的帐户</h4>
            </div>
            <div class="form">
                <input type="email" class="form-field animation a3" placeholder="输入账号" v-model="username">
                <input type="password" class="form-field animation a4" placeholder="输入密码" v-model="password">
                <p class="animation a5"><a href="#">忘记密码</a></p>
                <button class="animation a6" @click="login()">登录</button>
            </div>
        </div>
    </div>

</body>
</html>
<script src="../Script/vue.global.min.js"></script>
<script src="../Script/jquery-3.7.1.min.js"></script>
<script src="../Script/ktlapi.js"></script>
<script src="../Script/lodash.min.js"></script>
<script src="../Script/element-plus/zh-cn.js"></script>
<script src="../Script/element-plus/index.full.js"></script>
<script src="../Script/element-plus/index.iife.min.js"></script>
<script src="../Script/echarts-5.4.3/dist/echarts.js"></script>
<script src="../Script/sheetjs/xlsx.core.min.js"></script>
<script src="../Script/crypto-js.min.js"></script>

<script>

    var app = createApp({
        el: '#app',
        data() {
            return {
                username: "",
                password: ""
            }
        },
        methods: {
            login() {
                var user = new ktluser();
                user.login(this.username, this.password, function (data) {
                    if (!data.result) {
                        alert(data.msg);
                    } else {
                        if (user.hasRole(6) || user.hasRole(2)) {
                            window.location = 'index.aspx';
                        } else {
                            alert("尚未授权");
                        }
                    }
                });
            }
        },
        mounted: function () {
            var that = this;
            document.onkeydown = function (e) {
                if (e.code == 'Enter') {
                    that.login();
                }
            }
        }
    });
</script>
